package com.rabbitmq.learn.confirm.unsync;

import com.rabbitmq.client.*;
import com.rabbitmq.learn.common.ConnectionUtils;
import com.rabbitmq.learn.common.RabbitMqConstant;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * Created by Lxk on 2019/8/17.
 */
public class Receiver {

    public static void main(String[] args) throws IOException, TimeoutException {
        Connection con = ConnectionUtils.getConnection();
        Channel channel = con.createChannel();
        channel.queueDeclare(RabbitMqConstant.ConfirmUnsync.QUEUE_CONFIRM_UNSYNC,false,false,false,null);
        channel.basicConsume(RabbitMqConstant.ConfirmUnsync.QUEUE_CONFIRM_UNSYNC,true,new DefaultConsumer(channel){
            @Override
            public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
                String msg = new String(body,"utf-8");
                System.out.println("receive msg: " + msg);
            }
        });
    }

}
